package com.yanqu.road.entity.activity.unionwar.result;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.unionwar.UnionQunyingTimeInfo;
import com.yanqu.road.entity.activity.unionwar.enums.eTimeInfoPeriodType;

/**
 * 群英争霸-当前阶段
 */
public class CurrentTimeInfo {

    UnionQunyingTimeInfo timeInfo;

    eTimeInfoPeriodType periodType;


    public UnionQunyingTimeInfo getTimeInfo() {
        return timeInfo;
    }

    public void setTimeInfo(UnionQunyingTimeInfo timeInfo) {
        this.timeInfo = timeInfo;
    }

    public eTimeInfoPeriodType getPeriodType() {
        return periodType;
    }

    public void setPeriodType(eTimeInfoPeriodType periodType) {
        this.periodType = periodType;
    }

    /**
     * 当前周期开始5分钟后
     * @param activityInfo
     * @return
     */
    public boolean isAfterBeginTime5Min(ActivityInfo activityInfo){
        if(timeInfo == null){
            return false;
        }
        long gapSecond = System.currentTimeMillis() / 1000 - activityInfo.getBeginTime();
        if(gapSecond > (timeInfo.getBeginTime() + 5) * 60 && gapSecond < (timeInfo.getBeginTime() + timeInfo.getDurTime()) * 60){
            return true;
        }
        return false;
    }

    /**
     * 当前周期开始10分钟后
     * @param activityInfo
     * @return
     */
    public boolean isAfterBeginTime10Min(ActivityInfo activityInfo){
        if(timeInfo == null){
            return false;
        }
        long gapSecond = System.currentTimeMillis() / 1000 - activityInfo.getBeginTime();
        if(gapSecond > (timeInfo.getBeginTime() + 10) * 60 && gapSecond < (timeInfo.getBeginTime() + timeInfo.getDurTime()) * 60){
            return true;
        }
        return false;
    }

    /**
     * 当前周期结束前5分钟
     * @param activityInfo
     * @return
     */
    public boolean isBeforeDurTime5Min(ActivityInfo activityInfo){
        if(timeInfo == null){
            return false;
        }
        long gapSecond = System.currentTimeMillis() / 1000 - activityInfo.getBeginTime();

        if(gapSecond > (timeInfo.getBeginTime() + timeInfo.getDurTime() - 5) * 60 && gapSecond < (timeInfo.getBeginTime() + timeInfo.getDurTime()) * 60){
            return true;
        }
        return false;
    }

    /**
     * 当前周期开始n秒后
     * @param activityInfo
     * @param second
     * @return
     */
    public boolean isAfterBeginTimeNSecond(ActivityInfo activityInfo, int second){
        if(timeInfo == null){
            return false;
        }
        long gapSecond = System.currentTimeMillis() / 1000 - activityInfo.getBeginTime();
        if(gapSecond > (timeInfo.getBeginTime() * 60 + second) && gapSecond < (timeInfo.getBeginTime() + timeInfo.getDurTime()) * 60){
            return true;
        }
        return false;
    }

    /**
     * 当前周期结束前2分钟
     * @param activityInfo
     * @return
     */
    public boolean isBeforeDurTimeTwoMin(ActivityInfo activityInfo){
        if(timeInfo == null){
            return false;
        }
        long gapSecond = System.currentTimeMillis() / 1000 - activityInfo.getBeginTime();
        if(gapSecond > (timeInfo.getBeginTime() + timeInfo.getDurTime() - 2) * 60 && gapSecond < (timeInfo.getBeginTime() + timeInfo.getDurTime()) * 60){
            return true;
        }
        return false;
    }
}
